<template>
  <div class="sd">
    <van-nav-bar
      title="护眼模式"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />

    <van-cell
      left
      title="护眼模式"
      @click="changedark"
      style="text-align: left"
    >
      <template #right-icon>
        <van-switch v-model="checked" size="24" />
      </template>
    </van-cell>
  </div>
</template>


<script setup>
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
const router = useRouter();
const store = useStore();

const checked = ref(Boolean(store.state.dark));
const onClickLeft = () => {
  router.push({ path: "/hot", query: { dark: checked.value } });
};
const changedark = (e) => {
  store.commit("setdark", checked.value);
};

onMounted(async () => {
  // const { data: res } = await getlogin();
  // console.log(checked.value);
});
</script>
 


<style>
</style>